package com.hmall.common.client;

import com.hmall.common.pojo.Item;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

/**
 * @Description ItemClient
 * @Author potato
 * @Date 2024-03-29
 * 定义商品远程调用接口
 */
@FeignClient(value = "itemservice") //声明调用的商品微服务名
public interface ItemClient {
    /**
     * 调用用户微服中controller的方法
     */
    @GetMapping("/item/{id}")
    Item getItemById(@PathVariable Long id);

    /**
     * 事务减库存
     * @param itemId
     * @param num
     */
    @PutMapping("/item/stock/{itemId}/{num}")
    void deduct(@PathVariable Long itemId,@PathVariable Integer num);

    /**
     *订单超时手动加库存
     */
    @PutMapping("/item/refund/stock")
    void refundItemStock(@RequestBody Map<String,Object> map);

}
